package com.qingke.oms.command.shop;

import java.util.Set;

import com.qingke.oms.command.ShopCommand;
import com.qingke.oms.pojo.Goods;
import com.qingke.oms.pojo.GoodsStatistic;
import com.qingke.oms.pojo.Shop;
import com.qingke.oms.pojo.User;
import com.qingke.oms.util.OMSConsole;

public class ViewGoodsCommand extends ShopCommand implements UpdateGoodsStatistic{

	public ViewGoodsCommand(User user, Shop shop) {
		super(user, shop);
	}

	@Override
	public void execute() {
		updateGoodsStatistic();
		shop=dao.selectNewestShopById(shop.getId());
		Set<GoodsStatistic> list = shop.getGoodsStatistics();
		OMSConsole.println("-------goods list-------");
		for(GoodsStatistic gr:list){
			if(gr.getStock()>0){
				Goods goods=gr.getGoods();
				OMSConsole.print(goods);
				OMSConsole.println("      [Stock]:"+gr.getStock()+",[price]:"+gr.getPrice());
			}
		}
	}

}
